x86/pv: _toggle_guest_pt() may not skip TLB flush for shadow mode guests
authorJan Beulich <jbeulich@suse.com>
Tue, 5 Mar 2019 14:06:47 +0000 (15:06 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 5 Mar 2019 14:06:47 +0000 (15:06 +0100)
commite984846dad81218bbd8cbaec6df8e8a3530726dc
tree4a6968804df30c2d960a701c43d1582cefcd497e
parent4f9ab5f75c120a2cc0b58d651da75e03fc50d9e9
x86/pv: _toggle_guest_pt() may not skip TLB flush for shadow mode guests

For shadow mode guests (e.g. PV ones forced into that mode as L1TF
mitigation, or during migration) update_cr3() -> sh_update_cr3() may
result in a change to the (shadow) root page table (compared to the
previous one when running the same vCPU with the same PCID). This can,
first and foremost, be a result of memory pressure on the shadow memory
pool of the domain. Shadow code legitimately relies on the original
(prior to commit 5c81d260c2 ["xen/x86: use PCID feature"]) behavior of
the subsequent CR3 write to flush the TLB of entries still left from
walks with an earlier, different (shadow) root page table.

Restore the flushing behavior, also for the second CR3 write on the exit
path to guest context when XPTI is active. For the moment accept that
this will introduce more flushes than are strictly necessary - no flush
would be needed when the (shadow) root page table doesn't actually
change, but this information isn't readily (i.e. without introducing a
layering violation) available here.

This is XSA-294.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: 329b00e4d49f70185561d7cc4b076c77869888a0
master date: 2019-03-05 13:54:42 +0100
xen/arch/x86/pv/domain.c